package controller

import (
	"github.com/gin-gonic/gin"
	"log"
	"mygin_project/param"
	"mygin_project/service"
	"mygin_project/tool"
)

type MemberController struct {
	
}

//路由设置
func (controller *MemberController) Router(engine *gin.Engine)  {
	engine.POST("/api/login", controller.Login)
}

//路由方法
func (controller *MemberController) Login(c *gin.Context)  {
	var smsLoginParam param.SmsLoginParam

	log.Printf("body : %v", c.Request.Body)
	err := c.ShouldBind(&smsLoginParam)
	if err != nil {
		tool.ErrorResult(c, err)
	}
	log.Printf("params : %v", smsLoginParam)
	service := service.MemberService{Orm: tool.DbEngine}
	member, err := service.SmsLogin(smsLoginParam)
	if member != nil {
		tool.SuccessResult(c, member)
	}
	tool.ErrorResult(c, err)
}
